package material

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"go-zero-demo/app/datacenter/mq/internal/svc"
	"go-zero-demo/common/schema"
)

const MaxRetryCount = 3
const BatchSize = 500
const PageSize = 100

type Consumes struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewConsumes(ctx context.Context, svcCtx *svc.ServiceContext) *Consumes {
	return &Consumes{
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (s *Consumes) ConsumeTest1() {
	err := s.svcCtx.RabbitMq.Start(s.ctx, schema.QueueTaskTest1, NewConsumeTest1(s.ctx, s.svcCtx).Handle, 1, 1)
	if err != nil {
		panic(err)
	}
}

func (s *Consumes) ConsumeTest2() {
	err := s.svcCtx.RabbitMq.Start(s.ctx, schema.QueueTaskTest2, NewConsumeTest2(s.ctx, s.svcCtx).Handle, 1, 1)
	if err != nil {
		panic(err)
	}
}

func (s *Consumes) Start() {
	logx.Info("【第1个，消费任务启动。")
	go s.ConsumeTest1()
	logx.Info("【第2个，消费任务启动。")
	go s.ConsumeTest2()

}
